From c4c86bad1301e8b6b9ac0562475831b17f022b32 Mon Sep 17 00:00:00 2001 From: Henrik Laxhuber Date: Fri, 20 Apr 2018 17:04:14 +0200 Subject: [PATCH] Pass linker path to build script This change adds the environment variable LINKER to pass the path of the linker used by cargo to the build script. This ammends the variable RUSTC (the rustc binary used) to give the build script full knowledge of its environment. A specific usage example would be automatically generating bindings to system headers in cross compilation, e.g. by locating jni.h for android targets. --- src/cargo/core/compiler/custom_build.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cargo/core/compiler/custom_build.rs b/src/cargo/core/compiler/custom_build.rs index a219ddab5..e1e5ce92a 100644 --- a/src/cargo/core/compiler/custom_build.rs +++ b/src/cargo/core/compiler/custom_build.rs @@ -144,6 +144,7 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoRes .env("HOST", &cx.build_config.host_triple()) .env("RUSTC", &cx.build_config.rustc.path) .env("RUSTDOC", &*cx.config.rustdoc()?) + .env("LINKER", &cx.build_config.target.linker.as_ref().unwrap_or(&PathBuf::new())) .inherit_jobserver(&cx.jobserver); if let Some(links) = unit.pkg.manifest().links() { -- 2.30.2